﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CJJCH.Web.Manage
{
    public partial class ExpertDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitRequest();
                InitDataBind();
            }
            if (lblCompanyName.Text.Trim() == "")
            {
                LTP.Common.WindowClass.WindowBack("错误操作！");
            }
        }
        private void InitRequest()
        {
            if (Request.QueryString["ID"] != null)
            {
                lblID.Text = Request.QueryString["ID"].ToString();
            }
        }
        private void InitDataBind()
        {
            if (lblID.Text != "" && LTP.Common.CheckInput.CheckGUID(lblID.Text))
            {
                CJJCH.Model.T_NET_Expert model = new Model.T_NET_Expert();
                model = (new BLL.T_NET_Expert()).GetExpertModel(new Guid(lblID.Text.Trim()));

                if (model != null)
                {

                    lblCompanyName.Text = model.CompanyName;

                    lblCompanyAddress.Text = model.CompanyAddress;
                    lblPostCode.Text = model.PostCode;
                    lblContactName.Text = model.ContactName;
                    lblEmail.Text = model.UserEmail;
                    LblOfficeTel.Text = model.OfficeTel;
                    lblUserMobile.Text = model.UserMobile;
                    lblProjectName.Text = model.ProjectName;
                    lblProjectAddress.Text = model.ProjectAddress;
                    if (model.Third.MenuName != null)
                    {
                        lblStandardsType.Text = model.Third.MenuName;
                    }
                    else
                    {
                        trNone.Style.Add("display", " none");
                    }
                    lblJDMS.Text = model.JDMS.ToString();
                    lblDXSCS.Text = model.DXSCS.ToString();
                    lblRCSL.Text = model.RCSL.ToString();
                    lblZCSL.Text = model.ZCSL.ToString();
                    lblPSSJ.Text = DateTime.Parse(model.PSSJ.ToString()).ToString("yyyy/MM/dd");
                    lblSBSJ.Text = DateTime.Parse(model.SBSJ.ToString()).ToString("yyyy/MM/dd");
                    lblHYDZ.Text = model.HYDZ.ToString();
                    lnkSCWJONEName.Text = model.SCWJONEName;
                    lnkSCWJWOName.Text = model.SCWJTWOName;
                    lnkSCWJONEName.NavigateUrl = model.SCWJONE;
                    lnkSCWJWOName.NavigateUrl = model.SCWJTWO;
                    lblWJSM.Text = model.WJSM;
                    dropState.SelectedValue = model.PSZT;
                    txtPSZJ.Text = model.PSZJ;
                }
                else
                {
                    LTP.Common.WindowClass.WindowBack("操作错误！");
                }
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            string error = (new CJJCH.BLL.T_NET_Expert()).SetValue(new Guid(lblID.Text.Trim()), LTP.Common.StringClass.EncodeString(dropState.SelectedValue.Trim()), LTP.Common.StringClass.EncodeString(txtPSZJ.Text.Trim()));
            if (error == "")
            {
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "closewin", "alert('信息更新完成！');dg.cancel();", true);
            }
            else
            {
                LTP.Common.WindowClass.WindowBack(error);
            }
        }

    }
}